#ifndef DASYSTEMINFO_H
#define DASYSTEMINFO_H

#include <QString>
#include <QLabel>
#include <QTimer>
#include <QWidget>
#include <QPaintEvent>

class DASystemInfo : public QWidget
{
    Q_OBJECT
public:
    explicit DASystemInfo(QWidget *parent = nullptr);

    enum RateUnit {
        RateBit,
        RateByte,
        RateKb,
        RateMb,
        RateGb,
        RateTb,
        RateUnknow
    };
    Q_ENUM(RateUnit)

    enum Sensitive {
        Default,  // 大小写混合
        Upper,    // 全部大写
        Lower     // 全部小写
    };

    QString getCpuUsed();
    QString getMemUsed();
    void getNetUploadDownload();
signals:

private:
    QTimer *timer;
    long old_cpuAll = 0;
    long old_cpuFree = 0;
    long old_upload = 0;
    long old_download = 0;
    QLabel LabelMem,LabelCPU,LabelUpload,LabelDownload;
    QLabel MemRate,CPURate,UploadRate,DownloadRate;
    QString setRateUnitSensitive(DASystemInfo::RateUnit unit, DASystemInfo::Sensitive sensitive);
    double autoRateUnits(long speed, DASystemInfo::RateUnit &unit);

    void paintEvent(QPaintEvent *e);
};

#endif // DASYSTEMINFO_H
